Merge "Convert a few call_user_func*() calls to native PHP syntax"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 8 Mar 2019 20:50:07 +0000 (20:50 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 8 Mar 2019 20:50:07 +0000 (20:50 +0000)
.phpcs.xml
RELEASE-NOTES-1.33
autoload.php
includes/jobqueue/aggregator/JobQueueAggregator.php
includes/jobqueue/aggregator/JobQueueAggregatorNull.php [new file with mode: 0644]
languages/Language.php
languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki.htmlform.checker.js
resources/src/mediawiki.special.userlogin.signup.js

index b877c96..5a639ad 100644 (file)
                <exclude-pattern>*/includes/gallery/PackedOverlayImageGallery\.php</exclude-pattern>
                <exclude-pattern>*/includes/HistoryBlob\.php</exclude-pattern>
                <exclude-pattern>*/includes/htmlform/HTMLFormElement\.php</exclude-pattern>
-               <exclude-pattern>*/includes/jobqueue/aggregator/JobQueueAggregator\.php</exclude-pattern>
                <exclude-pattern>*/includes/libs/filebackend/FileBackendStore\.php</exclude-pattern>
                <exclude-pattern>*/includes/libs/filebackend/FSFileBackend\.php</exclude-pattern>
                <exclude-pattern>*/includes/libs/filebackend/SwiftFileBackend\.php</exclude-pattern>
index 111a6aa..b9331bc 100644 (file)
@@ -59,6 +59,8 @@ production.
 * Argon2 password hashing is now available, can be enabled via
   $wgPasswordDefault = 'argon2'. It's designed to resist timing attacks
   (requires PHP 7.2+) and GPU hacking (7.3+).
+* Special:CreateAccount now warns the user if their chosen username has to be
+  normalized.
 
 === External library changes in 1.33 ===
 
@@ -280,6 +282,8 @@ because of Phabricator reports.
     AuthManagerAuthPlugin, and AuthManagerAuthPluginUser.
   * The $wgAuth configuration setting and its use in Setup.php and unit tests
 * (T217772) The 'wgAvailableSkins' mw.config key in JavaScript, was removed.
+* Language::markNoConversion, deprecated in 1.32, has been removed. Use
+  LanguageConverter::markNoConversion instead.
 
 === Deprecations in 1.33 ===
 * The configuration option $wgUseESI has been deprecated, and is expected
index fab10fe..be37737 100644 (file)
@@ -705,7 +705,7 @@ $wgAutoloadLocalClasses = [
        'Job' => __DIR__ . '/includes/jobqueue/Job.php',
        'JobQueue' => __DIR__ . '/includes/jobqueue/JobQueue.php',
        'JobQueueAggregator' => __DIR__ . '/includes/jobqueue/aggregator/JobQueueAggregator.php',
-       'JobQueueAggregatorNull' => __DIR__ . '/includes/jobqueue/aggregator/JobQueueAggregator.php',
+       'JobQueueAggregatorNull' => __DIR__ . '/includes/jobqueue/aggregator/JobQueueAggregatorNull.php',
        'JobQueueAggregatorRedis' => __DIR__ . '/includes/jobqueue/aggregator/JobQueueAggregatorRedis.php',
        'JobQueueConnectionError' => __DIR__ . '/includes/jobqueue/exception/JobQueueConnectionError.php',
        'JobQueueDB' => __DIR__ . '/includes/jobqueue/JobQueueDB.php',
index 27ad88e..b44fc45 100644 (file)
@@ -157,24 +157,3 @@ abstract class JobQueueAggregator {
                return $pendingDBs;
        }
 }
-
-/**
- * @ingroup JobQueue
- */
-class JobQueueAggregatorNull extends JobQueueAggregator {
-       protected function doNotifyQueueEmpty( $wiki, $type ) {
-               return true;
-       }
-
-       protected function doNotifyQueueNonEmpty( $wiki, $type ) {
-               return true;
-       }
-
-       protected function doGetAllReadyWikiQueues() {
-               return [];
-       }
-
-       protected function doPurge() {
-               return true;
-       }
-}
diff --git a/includes/jobqueue/aggregator/JobQueueAggregatorNull.php b/includes/jobqueue/aggregator/JobQueueAggregatorNull.php
new file mode 100644 (file)
index 0000000..c44d70e
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Job queue aggregator code.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+/**
+ * @ingroup JobQueue
+ */
+class JobQueueAggregatorNull extends JobQueueAggregator {
+       protected function doNotifyQueueEmpty( $wiki, $type ) {
+               return true;
+       }
+
+       protected function doNotifyQueueNonEmpty( $wiki, $type ) {
+               return true;
+       }
+
+       protected function doGetAllReadyWikiQueues() {
+               return [];
+       }
+
+       protected function doPurge() {
+               return true;
+       }
+}
index 3dbde01..bbf2576 100644 (file)
@@ -4331,32 +4331,6 @@ class Language {
                $this->mConverter->updateConversionTable( $title );
        }
 
-       /**
-        * Prepare external link text for conversion. When the text is
-        * a URL, it shouldn't be converted, and it'll be wrapped in
-        * the "raw" tag (-{R| }-) to prevent conversion.
-        *
-        * This function is called "markNoConversion" for historical
-        * reasons *BUT DIFFERS SIGNIFICANTLY* from
-        * LanguageConverter::markNoConversion(), with which it is easily
-        * confused.
-        *
-        * @param string $text Text to be used for external link
-        * @param bool $noParse Wrap it without confirming it's a real URL first
-        * @return string The tagged text
-        * @deprecated since 1.32, use LanguageConverter::markNoConversion()
-        *  instead.
-        */
-       public function markNoConversion( $text, $noParse = false ) {
-               wfDeprecated( __METHOD__, '1.32' );
-               // Excluding protocal-relative URLs may avoid many false positives.
-               if ( $noParse || preg_match( '/^(?:' . wfUrlProtocolsWithoutProtRel() . ')/', $text ) ) {
-                       return $this->mConverter->markNoConversion( $text );
-               } else {
-                       return $text;
-               }
-       }
-
        /**
         * A regular expression to match legal word-trailing characters
         * which should be merged onto a link of the form [[foo]]bar.
index 54ce65e..d2d77f9 100644 (file)
        "badretype": "The passwords you entered do not match.",
        "usernameinprogress": "An account creation for this user name is already in progress.\nPlease wait.",
        "userexists": "Username entered already in use.\nPlease choose a different name.",
+       "createacct-normalization": "Your username will be adjusted to \"$2\" due to technical restrictions.",
        "loginerror": "Login error",
        "createacct-error": "Account creation error",
        "createaccounterror": "Could not create account: $1",
index 383857e..d48bd94 100644 (file)
        "badretype": "Used as error message when the new password and its retype do not match.",
        "usernameinprogress": "Used as error message in creating a user account.",
        "userexists": "Used as error message in creating a user account.",
+       "createacct-normalization": "Used as warning message on account creation when user name is adjusted silently due to technical restrictions (e.g. first letter capitalized, underscores converted to spaces).\nParameters:\n* $1 - the old username\n* $2 - the new username",
        "loginerror": "Used as title of error message.\n{{Identical|Login error}}",
        "createacct-error": "Used as heading for the error message.",
        "createaccounterror": "Parameters:\n* $1 - an error message",
index f114572..51d4d2f 100644 (file)
@@ -2319,6 +2319,7 @@ return [
                        'createacct-emailrequired',
                        'noname',
                        'userexists',
+                       'createacct-normalization',
                ],
                'dependencies' => [
                        'mediawiki.api',
index 78e9f5f..ecaddd8 100644 (file)
@@ -73,7 +73,7 @@
 
                if ( value === '' ) {
                        this.currentValue = value;
-                       this.setErrors( [] );
+                       this.setErrors( true, [] );
                        return;
                }
 
 
                                that.currentValue = value;
 
-                               if ( info.valid ) {
-                                       that.setErrors( [], forceReplacement );
-                               } else {
-                                       that.setErrors( info.messages, forceReplacement );
-                               }
+                               that.setErrors( info.valid, info.messages, forceReplacement );
                        } ).fail( function () {
                                that.currentValue = null;
-                               that.setErrors( [] );
+                               that.setErrors( true, [] );
                        } );
 
                return currentRequestInternal;
 
        /**
         * Display errors associated with the form element
+        * @param {boolean} valid Whether the input is still valid regardless of the messages
         * @param {Array} errors Error messages. Each error message will be appended to a
         *  `<span>` or `<li>`, as with jQuery.append().
         * @param {boolean} [forceReplacement] Set true to force a visual replacement even
         * @return {mw.htmlform.Checker}
         * @chainable
         */
-       mw.htmlform.Checker.prototype.setErrors = function ( errors, forceReplacement ) {
+       mw.htmlform.Checker.prototype.setErrors = function ( valid, errors, forceReplacement ) {
                var $oldErrorBox, tagName, showFunc, text, replace,
                        $errorBox = this.$errorBox;
 
                                // FIXME: Use CSS transition
                                // eslint-disable-next-line no-jquery/no-slide
                                $errorBox
-                                       .attr( 'class', 'error' )
+                                       .attr( 'class', valid ? 'warning' : 'error' )
                                        .empty()
                                        .append( errors.map( function ( e ) {
                                                return errors.length === 1 ? e : $( '<li>' ).append( e );
                                        } ) )
                                        .slideDown();
                        };
-                       if ( $oldErrorBox !== $errorBox && $oldErrorBox.hasClass( 'error' ) ) {
+                       if (
+                               $oldErrorBox !== $errorBox &&
+                               ( $oldErrorBox.hasClass( 'error' ) || $oldErrorBox.hasClass( 'warning' ) )
+                       ) {
                                // eslint-disable-next-line no-jquery/no-slide
                                $oldErrorBox.slideUp( showFunc );
                        } else {
index 777f5e9..fff2d4e 100644 (file)
@@ -30,7 +30,7 @@
                updateForCheckbox();
        } );
 
-       // Check if the username is invalid or already taken
+       // Check if the username is invalid or already taken; show username normalisation warning
        mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
                var $usernameInput = $root.find( '#wpName2' ),
                        $passwordInput = $root.find( '#wpPassword2' ),
                        // We could just use .then() if we didn't have to pass on .abort()…
                        var d, apiPromise;
 
+                       // Leading/trailing/multiple whitespace characters are always stripped in usernames,
+                       // this should not require a warning. We do warn about underscores.
+                       username = username.replace( / +/g, ' ' ).trim();
+
                        d = $.Deferred();
                        apiPromise = api.get( {
                                action: 'query',
                                                                return m.html;
                                                        } ) : []
                                                } );
+                                       } else if ( userinfo.name !== username ) {
+                                               d.resolve( { valid: true, messages: [
+                                                       mw.message( 'createacct-normalization', username, userinfo.name ).parseDom()
+                                               ] } );
                                        } else {
                                                d.resolve( { valid: true, messages: [] } );
                                        }